// const prefix = 'http://192.168.0.102:8808/api/task';
const prefix = 'https://cdlapi.yaojunzhiku.com/api/task';

const GetTaskList = async () => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: prefix + '/list',
			method: 'GET',
			success: (res) => {
				resolve(res.data)
			}
		});
	})
}

const GetTask = async (id) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: prefix + '/info/' + id,
			method: 'GET',
			header: {
				'uuid': uni.getStorageSync('UUID')
			},
			success: (res) => {
				resolve(res.data)
			}
		});
	})
}


const PostTask = async (data) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: prefix + '/join',
			method: 'POST',
			data: data,
			success: (res) => {
				resolve(res.data)
			}
		});
	})
}

const GetMineJoinList = async () => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: prefix + '/mineJoin',
			method: 'get',
			header: {
				'uuid': uni.getStorageSync('UUID')
			},
			success: (res) => {
				resolve(res.data)
			}
		});
	})
}


const GetJoinInfo = async (id) => {
	return new Promise((resolve, reject) => {
		uni.request({
			url: prefix + '/joinInfo/' + id,
			method: 'GET',
			success: (res) => {
				resolve(res.data)
			}
		});
	})
}

export default {
	GetTaskList,
	GetTask,
	PostTask,
	GetMineJoinList,
	GetJoinInfo
};